﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Toolbox"
                    xmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
    <Style x:Key="ButtonFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="2"
                               StrokeThickness="1"
                               Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
                               StrokeDashArray="1 2"
                               SnapsToDevicePixels="true"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <LinearGradientBrush x:Key="ButtonNormalBackground"
                         StartPoint="0,0"
                         EndPoint="0,1">
        <LinearGradientBrush.GradientStops>
            <GradientStop Color="#F3F3F3"
                          Offset="0"/>
            <GradientStop Color="#EBEBEB"
                          Offset="0.5"/>
            <GradientStop Color="#DDDDDD"
                          Offset="0.5"/>
            <GradientStop Color="#CDCDCD"
                          Offset="1"/>
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>
    <SolidColorBrush x:Key="ButtonNormalBorder"
                     Color="#FF707070"/>

    <Style TargetType="{x:Type local:Toolbox}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:Toolbox}">
                    <Grid>
                        <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                            <StackPanel IsItemsHost="True" />
                        </Border>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" />
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <ContentPresenter Margin="3" />
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:ToolboxCategory}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ToolboxCategory}">
                    <Grid Background="Transparent">
                        <theme:ButtonChrome Name="PART_SelectedItem"
                                      Background="{TemplateBinding Background}"
                                      BorderBrush="{TemplateBinding BorderBrush}"
                                      RenderDefaulted="{TemplateBinding Button.IsDefaulted}"
                                      RenderMouseOver="{TemplateBinding IsMouseOver}"
                                      RenderPressed="{TemplateBinding IsPressed}"
                                      SnapsToDevicePixels="true" Margin="2">
                            <Grid>
                                <ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="Center" VerticalAlignment="Center" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Content="{TemplateBinding MainItem}" />
                                <Canvas Name="ExpanderCanvas" Visibility="Collapsed">
                                    <Path Width="5.57359" Height="8.70267" Canvas.Right="2" Canvas.Bottom="2" Stretch="Fill" Fill="#FF5E5E5E" Data="F1 M 44.1443,39.0107L 38.5707,34.6594L 38.5707,43.362L 44.1443,39.0107 Z "/>
                                </Canvas>
                            </Grid>
                        </theme:ButtonChrome>
                        <Popup x:Name="Popup" Placement="Right" IsOpen="{TemplateBinding IsExpanded}" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade" HorizontalOffset="-2">
                            <Border Name="SubmenuBorder" SnapsToDevicePixels="True" BorderThickness="0" Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" Padding="2,0,0,0" CornerRadius="2">
                                <StackPanel Orientation="Horizontal" IsItemsHost="True" />
                            </Border>
                        </Popup>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="True">
                            <Setter TargetName="Popup" Property="PopupAnimation" Value="None" />
                        </Trigger>
                        <Trigger Property="IsExpanderVisible" Value="True">
                            <Setter TargetName="ExpanderCanvas" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="#ADADAD"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
        <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Width" Value="45" />
        <Setter Property="Height" Value="45" />
    </Style>

    <Style TargetType="{x:Type local:ToolboxItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ToolboxItem}">
                    <theme:ButtonChrome Name="Chrome"
                                      Background="{TemplateBinding Background}"
                                      BorderBrush="{TemplateBinding BorderBrush}"
                                      RenderDefaulted="{TemplateBinding Button.IsDefaulted}"
                                      RenderMouseOver="{TemplateBinding IsMouseOver}"
                                      RenderPressed="{TemplateBinding IsPressed}"
                                      SnapsToDevicePixels="true">
                        <ContentPresenter Margin="{TemplateBinding Padding}"
                              VerticalAlignment="Center"
                              HorizontalAlignment="Center"
                              RecognizesAccessKey="True"
                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                    </theme:ButtonChrome>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsKeyboardFocused"
                                 Value="true">
                            <Setter TargetName="Chrome" Property="RenderDefaulted" Value="true"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="#ADADAD"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
        <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Width" Value="40" />
        <Setter Property="Height" Value="40" />
        <Setter Property="Padding" Value="3" />
        <Setter Property="Margin" Value="2" />
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Visibility" Value="Collapsed" />
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>